<template>
  <view class="info-container">
    <view class="info-header">
      <image class="header-tx" :src="userInfo.avatarUrl"></image>
      <view class="header-name">{{userInfo.nickName}}</view>
    </view>
    <view class="info-body">
      <!-- 上 -->
      <view class="info-nav">
        <view class="info-nav-item">
          <text>8</text>
          <text>收藏的店铺</text>
        </view>
        <view class="info-nav-item">
          <text>14</text>
          <text>收藏的商品</text>
        </view>
        <view class="info-nav-item">
          <text>18</text>
          <text>关注的商品</text>
        </view>
        <view class="info-nav-item">
          <text>84</text>
          <text>足迹</text>
        </view>
      </view>
      <!-- 中 -->
      <view class="info-order">
        <view class="info-order-title">我的订单</view>
        <view class="info-order-list">
          <view class="order-list-item">
            <image class="icon" src="/static/my-icons/icon1.png"></image>
            <text>待付款</text>
          </view>
          <view class="order-list-item">
            <image class="icon" src="/static/my-icons/icon2.png"></image>
            <text>待收货</text>
          </view>
          <view class="order-list-item">
            <image class="icon" src="/static/my-icons/icon3.png"></image>
            <text>退款/退货</text>
          </view>
          <view class="order-list-item">
            <image class="icon" src="/static/my-icons/icon4.png"></image>
            <text>全部订单</text>
          </view>
        </view>
      </view>
      <!-- 下 -->
      <view class="info-detail">
        <view class="detail-item">
          <view class="detail-item-text">收货地址</view>
          <uni-icons type="right" size="18"></uni-icons>
        </view>
        <view class="detail-item">
          <view class="detail-item-text">联系客服</view>
          <uni-icons type="right" size="18"></uni-icons>
        </view>
        <view class="detail-item" @click="logout">
          <view class="detail-item-text">退出登录</view>
          <uni-icons type="right" size="18"></uni-icons>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import {mapState, mapMutations} from "vuex"
  export default {
    name:"UserInfo",
    data() {
      return {
        
      };
    },
    computed: {
      ...mapState("userAbout", ['userInfo'])
    },
    methods: {
      ...mapMutations('userAbout', ['UPDATETOKEN', 'UPDATEUSERINFO']),
      ...mapMutations('addressAbout', ['UPDATEADDRESS']),
      // 退出登录
      logout() {
        uni.showModal({
          content: "确认退出登录？",
          success: res => {
            if (res.confirm) {
              // 清除用户信息和token、收货地址
              this.UPDATETOKEN('')
              this.UPDATEUSERINFO({})
              this.UPDATEADDRESS({})
            }
          }
        })
      }
    }
  }
</script>

<style lang="scss">
  .info-container {
    height: 100%;
    background-color: #f4f4f4;
    .info-header {
      background-color: #C00000;
      height: 400rpx;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .header-tx {
        width: 90px;
        height: 90px;
        border: 2px solid #fff;
        border-radius: 50%;
        box-shadow: 1px #000;
        display: block;
      }
      .header-name {
        color: #FFF;
        margin: 10px 0;
        font-size: 16px;
        font-weight: 700;
      }
    }
    .info-body {
      width: 94%;
      margin: auto;
      position: relative;
      box-sizing: border-box;
      top: -10px;
      border-radius: 3px;
      .info-nav {
        background-color: #fff;
        border-bottom: 1px solid #f4f4f4;
        display: flex;
        border-radius: 3px;
        width: 100%;
        justify-content: space-around;
        .info-nav-item {
          display: flex;
          flex-direction: column;
          align-items: center;
          font-size: 13px;
          padding: 8px 0;
        }
      }
      .info-order {
        margin-top: 10px;
        padding: 0 8px;
        border-radius: 3px;
        background-color: #fff;
        border-bottom: 1px solid #f4f4f4;
        .info-order-title {
          padding: 8px 5px;
        }
        .info-order-list {
          display: flex;
          justify-content: space-around;
          .order-list-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            font-size: 13px;
            padding: 10px 0;
            .icon {
              width: 35px;
              height: 35px;
              margin-bottom: 3px;
            }
          }
        }
      }
      .info-detail {
        background-color: #fff;
        border-radius: 3px;
        margin-top: 10px;
        width: 100%;
        .detail-item {
          display: flex;
          justify-content: space-between;
          padding: 15px 12px;
          align-items: center;
          color: #000;
        }
      } 
    }
  }
  
</style>